package com.itheima.day06;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Demo05 {
    public static void main(String[] args) {
        HashMap<Integer, String> hashMap = new HashMap<>();
        hashMap.put(1, "王五");
        hashMap.put(2, "张三");
        hashMap.put(1, "李四");
        System.out.println("集合大小：" + hashMap.size());

        Set<Integer> keySet = hashMap.keySet();
        for (Integer integer : keySet) {
            System.out.println(hashMap.get(integer));

        }

        Set<Map.Entry<Integer, String>> entries = hashMap.entrySet();
        for (Map.Entry<Integer, String> entry : entries) {
            Integer key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key +":"+ value);
        }

        System.out.println("=====================");
        System.out.println(hashMap.get(1));
        System.out.println(hashMap.get(10));
        System.out.println(hashMap.containsKey(10));
        System.out.println(hashMap.remove(1));
        System.out.println(hashMap);
    }
}
